package net.badcurrent.ldapodm;

import org.springframework.ldap.LdapTemplate;
import net.badcurrent.ldapodm.ldap.DistinguishedNameFactory;
import net.badcurrent.ldapodm.typeconverter.TypeConverter;

import java.util.Map;

/**
 * <code>SessionFactory</code> is responsible for creating <code>Session</code> instances.
 * Its implementations should be thread safe.
 *
 * @author John D'Emic <john.demic@gmail.com>
 */
public interface SessionFactory {
    /**
     * Creates a new <code>Session</code>.
     * @return A new <code>Session</code>.
     */
    Session openSession();

    /**
     * Set the Spring <code>LdapTemplate</code>.
     * @param ldapTemplate
     */
    void setLdapTemplate(LdapTemplate ldapTemplate);

    /**
     * Register the types the <code>Session</code>s are providing mapping capability for.
     * @param types
     */
    void setTypes(Class[] types);

    /**
     * Register the <code>DistinguishedNameFactories</code>
     * @param distinguishedNameFactories
     */
    void setDistinguishedNameFactories(Map<Class, DistinguishedNameFactory> distinguishedNameFactories);

    /**
     * Set the baseDn for all <code>Session</code> instances.
     * @param baseDn
     */
    void setBaseDn(String baseDn);

    /**
     * Set the <code>TypeConverters</code> .
     * @param typeConverters
     */
    void setTypeConverters(Map<Class, TypeConverter> typeConverters);
}
